//***********************************************************************************************//
/// \file     uclog_demo.c
/// \version  0.1.0
/// \brief    This is a demo how to use UCLOG library.
/// \author   Krystian Rebas
/// \details  Sorry, no user manual, learn from the code ;p
///           For more details about UCLOG usage see uclog.c/h/cfg files.
/// \note     Copyright (C) 2012 by Krystian Rebas.
///           All rights reserved.
///
///           Redistribution and use in source and binary forms, with or without
///           modification, are permitted provided that the following conditions are met: 
///           
///           1. Redistributions of source code must retain the above copyright notice, this
///           list of conditions and the following disclaimer. 
///           2. Redistributions in binary form must reproduce the above copyright notice,
///           this list of conditions and the following disclaimer in the documentation
///           and/or other materials provided with the distribution. 
///
///           THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
///           ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
///           WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
///           DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
///           ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
///           (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
///           LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
///           ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
///           (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
///           SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
///
//***********************************************************************************************//
#include <stdio.h>

//log.h must be always include in file that want to use LOG macros!
#include "uclog.h"

int main(int argc, char* argv[])
{
  int condition;
	printf("UCLOG demo\n");
#if (UCLOG_MODE == USE_MEM_BUFFER)
  printf("LOG configuret to use memory buffer, collecting log data to memory no prtinting it to stdout...\n\n");
#endif

  LOG(INFO,("This is a simple UCLOG message"));
  LOG(INFO,("LOG macros accepts same formatting string and variable arguments as standard prinf."));
  LOG(INFO,("\nExample of advaced usage:\nvalue=%d\nstring=\"%s\"\netc...", 10, "UCLOG rocks!"));
  LOG(INFO,("As you can see you don't need to remember about putting \\n in format string - UCLOG takes care on it \
            and starts each message at new line!"));
  LOG(INFO,("(But you can do it manually as well or use eqivalent LOG_CR macro)"));
  LOG_CR(INFO);
  
  LOG(INFO,("Such messages are logged for all non-zero LOG_SEVERITY_LEVEL values"));
  LOG(WARNING,("Here is a warning message with some variable/value = %d ", 10));
  LOG(WARNING,("WARNING messages are logged only for LOG_SEVERITY_LEVEL = 1 or below"));
  LOG_CR(WARNING);
  LOG(ERROR,("And here is an error message, such messages are logged only for LOG_SEVERITY_LEVEL = 2 or below"));
  LOG_CR(ERROR);

  LOG(INFO,("Sorry, no FATAL severity messages demo now - it will terminate program..."));
  condition = 1;
  LOG_IF(WARNING, ("LOG_IF macro provides you also conditional logging for %d bucks",0), condition);
  condition = 0;

  LOG_IF(INFO, ("SO THIS WILL NOT BE LOGGED!!!"), condition);
  condition = 0;
  LOG_ASSERT(("LOG_ASSERT is same as LOG_IF(FATAL) and %cerminates pr%dgram", 't',0), condition);


#if (UCLOG_MODE == USE_MEM_BUFFER)
  printf("Logging done, buffer content is:\n--BEGIN--%s\n--END--\n", UCLOG_BUFFER);
#endif
  getch();
	return 0;
}

